import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import VueSetupExtend from 'vite-plugin-vue-setup-extend';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
export default defineConfig({
	base: './',
	plugins: [
		vue(),
		VueSetupExtend(),
		AutoImport({
			resolvers: [ElementPlusResolver()]
		}),
		Components({
			resolvers: [ElementPlusResolver()]
		})
	],
	optimizeDeps: {
		include: ['schart.js']
	},
	server: {
		// 配置本地端口
		/*port: 8000,*/
		// 配置代理信息
		proxy: {
			// 配置请求映射路径:只要是/api开头的请求都使用下面的配置信息
			'/api': {
				// 配置目标服务器地址
				target: 'http://localhost:8080',
				// 允许跨域
				changeOrigin:true,
				// url重写
				rewrite:(path)=>path.replace(/^\/api/,'')
			},
			'/apc': {
				// 配置目标服务器地址
				target: 'https://echarts.apache.org',
				// 允许跨域
				changeOrigin:true,
				// url重写
				rewrite:(path)=>path.replace(/^\/apc/,'')
			}
		}
	}
});
